package com.thread;

public class MyRunnable4 implements Runnable {
    private int count=0;
    private int num=100;
    @Override
    public void run() {


       while(true){

           synchronized (this){
               if (num==0){
                   break;
               }
               count++;
               num--;
               System.out.println(
                       Thread.currentThread().getName()+
                       "第"+count+"张票售出"+"还剩："+num+"张票");

           }

        }
    }
}
